import { request } from '@/utils/http' //后面默认index
import type {
   getHospitalListSearchParamsType,
   hospitalListReqReturnType,
   getProvinceReturnType,
   hospitalDetailReturnType,
   hosDepartmentListType,
   hosScheduleRuleParamsType,
   hosScheduleRuleReturnTypes,
   findScheduleListParamsType,
   findScheduleListType
  } from './model/hospitalListType'

//1.获取医院列表详情数据的请求 searchparams是吧limit后面其他的参数放到params比如hoscode....
export const getHospitalListRequest = (page:number,limit:number,searchParams:getHospitalListSearchParamsType) => {
return request.get<any,hospitalListReqReturnType>(`/admin/hosp/hospital/${page}/${limit}`,{
   params:searchParams
}
)
}
//2.请求所有的省份   这个是接口有问题后台的事情只用传provice 
export const getProvinceRequest = () => {
   return request.get<any, getProvinceReturnType>(
     "/admin/cmn/dict/findByDictCode/province"
   );
 };
 //3.请求所有市或者区 id就是value这里面   这里面返回值跟省份一样 俩写成一个接口了
 export const getCityOrDistrictRequest = (value:string) => {
   return request.get<any,getProvinceReturnType> (`/admin/cmn/dict/findByParentId/${value}`)
 }
 
 //4.请求医院详情信息  点查看的请求 只有第一条数据有id 后端偷懒
 export const getHosListDetailRequest = (id:string) =>{
  return request.get<any,hospitalDetailReturnType> (
    `/admin/hosp/hospital/show/${id}`
    )
 }
 //5.医院上下线的请求
 export const getRequestChangeStatus = (id:string,status:0 | 1) => {
  return request.get<any,null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
 }
 //6.医院所有科室的请求
 export const hospitalDepartmentRequest = (hoscode:string) => {
  return request.get<any,hosDepartmentListType>(`/admin/hosp/department/${hoscode}`)
 }

 //7.某个科室的详细排班时间请求  这是{}通过对象结构来接收为了统一配置类型 
 export const hosScheduleRuleRequest=({page,limit,hoscode,depcode}:hosScheduleRuleParamsType) => {
  return request.get<any,hosScheduleRuleReturnTypes>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
 }

 //8.获取某个科室某个时间具体详情
 export const findScheduleListRequest = ({hoscode,depcode,workDate }:findScheduleListParamsType ) => {
 return request.get<any,findScheduleListType>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
 }